package com.yyds.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yyds.common.MyJSON;
import com.yyds.mapper.HospitalDoctorMapper;
import com.yyds.pojo.HospitalDoctor;
import com.yyds.service.HospitalDoctorService;
import com.yyds.vo.HospitalDoctorPieVo;
import com.yyds.vo.HospitalDoctorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@SuppressWarnings({"all"})
@Service("HospitalDoctorService")
public class HospitalDoctorServiceImpl implements HospitalDoctorService {

    @Autowired
    @Qualifier("hospitalDoctorMapper")
    private HospitalDoctorMapper hospitalDoctorMapper;

//    @Override
//    public MyJSON<HospitalDoctor> queryAllHospitalDoctorService(Map<String, Object> params) {
//        Integer page = Integer.parseInt(params.get("page") + "");
//        Integer limit = Integer.parseInt(params.get("limit") + "");
//        PageHelper.startPage(page, limit);
//        List<HospitalDoctor> hospitalDoctors =  hospitalDoctorMapper.queryAllHospitalDoctorMapper(params);
//        PageInfo<HospitalDoctor> pageInfo = new PageInfo<>(hospitalDoctors);
//        MyJSON<HospitalDoctor> hospitalDoctorMyJSON = new MyJSON<>();
//        hospitalDoctorMyJSON.setCount(pageInfo.getTotal());
//        hospitalDoctorMyJSON.setData(pageInfo.getList());
//        hospitalDoctorMyJSON.setMsg("全部医生信息");
//        hospitalDoctorMyJSON.setCode(0);
//
//        return hospitalDoctorMyJSON;
//    }

    @Override
    public MyJSON<HospitalDoctorVo> queryAllHospitalDoctorService(Map<String, Object> params) {
        Integer page = Integer.parseInt(params.get("page") + "");
        Integer limit = Integer.parseInt(params.get("limit") + "");
        PageHelper.startPage(page, limit);
        List<HospitalDoctorVo> hospitalDoctors =  hospitalDoctorMapper.queryAllHospitalDoctorMapper(params);
        PageInfo<HospitalDoctorVo> pageInfo = new PageInfo<>(hospitalDoctors);
        MyJSON<HospitalDoctorVo> hospitalDoctorMyJSON = new MyJSON<>();
        hospitalDoctorMyJSON.setCount(pageInfo.getTotal());
        hospitalDoctorMyJSON.setData(pageInfo.getList());
        hospitalDoctorMyJSON.setMsg("全部医生信息");
        hospitalDoctorMyJSON.setCode(0);
        return hospitalDoctorMyJSON;
    }

    @Override
    public Integer insertHospitalDoctorService(HospitalDoctor hospitalDoctor) {

        return hospitalDoctorMapper.insertHospitalDoctorMapper(hospitalDoctor);
    }

    @Override
    public Integer deleteHospitalDoctorService(Integer doctor_id) {
        return hospitalDoctorMapper.deleteHospitalDoctorMapper(doctor_id);
    }

    @Override
    public Integer updateHospitalDoctorService(HospitalDoctor doctor) {
        return hospitalDoctorMapper.updateHospitalDoctorMapper(doctor);
    }

    @Override
    public List<HospitalDoctorPieVo> sexPicHospitalDoctorService() {
        return hospitalDoctorMapper.sexPicHospitalDoctorMapper();
    }

}
